home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.823 < prev    next >
Text File  |  1992-02-06  |  2KB  |  53 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;\f2\fswiss Helvetica;}
  2. \paperw13040
  3. \paperh10800
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f0\b0\i0\ul0\fs28\fc0 textfield form firstresponder 
  8. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  9. \
  10. Q:  Why won't my textField become firstResponder?  The following code is in my 
  11. \b appDidInit:
  12. \b0  method:\
  13. \
  14.  
  15. \f1\fs24     [[NXApp mainWindow] makeKeyAndOrderFront:self];\
  16.     [[NXApp mainWindow] makeFirstResponder:myTextField];\
  17.  
  18. \f0\fs28     \
  19. The typing cursor does not appear in myTextField.  In the debugger, 
  20. \b makeFirstResponder
  21. \b0  returns the id of the window as it should.  And when asked, the window claims that the textField 
  22. \i is
  23. \i0  the firstResponder. What's going on?\
  24.  
  25. \fc0 \
  26. A: The problem is that 
  27. \b makeFirstResponder
  28. \b0  just sets the firstResponder.  It does not modify the selection. You have to explicitly set the selection if you want the cursor to appear in the TextField.  The method 
  29. \b selectText
  30. \b0  will do the trick—and it calls 
  31. \b makeFirstResponder
  32. \b0  for you.  Try using the following code instead:\
  33. \
  34.     
  35. \f1\fs24 [[NXApp mainWindow] makeKeyAndOrderFront:self];\
  36.     [myTextField selectText];\
  37.  
  38. \f0\fs28 \
  39. The same is true of Form objects as well. For Forms you must do the following:\
  40. \
  41.     
  42. \f1\fs24 [[NXApp mainWindow] makeKeyAndOrderFront:self];\
  43.     [myForm selectTextAt:0];\
  44.  
  45. \f0\fs28 \
  46. \
  47. QA823\
  48. \
  49. Valid for 1.0\
  50. Valid for 2.0\
  51. \
  52.  
  53.